{template nheader.html}
<link href="{THEME_PATH}admin/global/css/publics_class_edit.css" rel="stylesheet"  />
<script src="{THEME_PATH}admin/global/scripts/publics_class_edit.js"></script>

<script src="{THEME_PATH}admin/global/scripts/aliyun-upload-sdk1.3.1.min.js"></script>
<script src="{THEME_PATH}admin/global/scripts/aliyun-oss-sdk4.13.2.min.js"></script>
<script src="{THEME_PATH}admin/global/scripts/es6-promise.min.js"></script>
<script>
    function uploadFile(){
        //alert('123');
        var myform = new FormData();
        myform.append('img',$('#load_img')[0].files[0]);
        // console.log(s);return false;
        $.ajax({
            url: "admin.php?c=banner&m=uploadImg",
            type: "POST",
            data: myform,
            contentType: false,
            processData: false,
            success: function (data) {
                console.log(data);
                var obj = JSON.parse(data);
                if(obj.status == 1){
                    $('input[name="upload_img"]').val(obj.img_url);
                    $(".image-data").html(obj.img_url);
                    $('.update-class-pic').css('cssText','background-image:url('+obj.img_url+');');
                    $(".update-word-add").fadeOut();
                }
                else{
                    $(".image-data").text("格式错误，请重新选择");
                    $(".update-word-add").fadeIn();
                }
            },
            error:function(data){
                console.log(data);
            }
        });
    }
</script>
<div class="step-display">
    <div>
        <span>1</span>
        <span>选择课程分类</span>
    </div>
    <div>
        <span>2</span>
        <span>填写课程信息</span>
    </div>
    <div>
        <span>3</span>
        <span>课程发布成功</span>
    </div>
</div>
<form class="form-horizontal" action="" method="post" id="myform" name="myform" style="margin-top:30px;margin-bottom: 70px;">
    <input type="hidden" name="upload_img" value=""/>

    <input type="hidden" name="grade"/>
    <input type="hidden" name="subject"/>
    <input type="hidden" name="course_type"/>

    <div class="portlet light bordered">
        <div class="portlet-title">
            <div class="caption">
                <span class="caption-subject font-green bold uppercase">
                    <span style="font-family: FontAwesome;"></span>
                    <!-- {$name} -->
                    <span class="title">
                        {fc_lang('课程基本信息')}
                    </span>
                </span>
            </div>
        </div>
        <div class="portlet-body">
            <div class="portlet-body form">
                <div class="form-body">

                    <div class="form-page-1">

                        <div class="page-recently-select">
                            <label>{fc_lang('您最近使用的商品分类')}：</label>
                            <select>
                                <option value="">请选择</option>
                            </select>
                        </div>

                        <div class="page-class-my-select">

                            <div class="type">
                                <div class="title">{fc_lang('选择课程类型')}</div>
                                <div class="content">
                                    <div>1V4</div>
                                    <div>1V1</div>
                                    <div>专题课</div>
                                    <div>录播课</div>
                                </div>
                            </div>

                            <div class="stage">
                                <div class="title">{fc_lang('选择适用年级')}</div>
                                <div class="content">
                                    {loop $stages $key $vals}
                                    <div>{$vals}</div>
                                    {/loop}
                                </div>
                            </div>

                            <div class="subject">
                                <div class="title">{fc_lang('选择学科')}</div>
                                <div class="content">
                                    {loop $subjects $k $sub}
                                    <div>{$sub}</div>
                                    {/loop}
                                </div>
                            </div>

                        </div>
                    </div>

                    <div class="form-page-2">

                        <div class="form-group class-course-sorts">
                            <label class="col-md-2 control-label">
                                <span class="le_required">*</span>
                                {fc_lang('课程分类')}：
                            </label>
                            <div class="col-md-9">
                                <div class="radio-list">{$data['course_type']}/{$data['grade']}/{$data['subject']}</div>
                                <div class="course-edit">编辑</div>
                            </div>
                        </div>

                        <div class="form-group record-class-teacher">
                            <label class="col-md-2 control-label">
                                <span class="le_required">*</span>
                                {fc_lang('授课老师')}：
                            </label>
                            <div class="col-md-9">
                                <label>{dr_field_input('name','Text', $field['name']['setting'], $data['name'])}</label>
                            </div>
                        </div>

                        <div class="form-group ">
                            <label class="col-md-2 control-label">
                                <span class="le_required">*</span>
                                {fc_lang('课程标题')}：
                            </label>
                            <div class="col-md-9">
                                <div class="radio-list">
                                    <label>{dr_field_input('title', 'Text', $field['title']['setting'], $data['title'])}</label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group ">
                            <label class="col-md-2 control-label">
                                <span class="le_required">*</span>
                                {fc_lang('副标题')}：
                            </label>
                            <div class="col-md-9">
                                <div class="radio-list">
                                    <label>{dr_field_input('aux_title', 'Text', $field['aux_title']['setting'], $data['aux_title'])}</label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group ">
                            <label class="col-md-2 control-label">
                                <span class="le_required">*</span>
                                {fc_lang('关键词')}：
                            </label>
                            <div class="col-md-9">
                                <div class="radio-list">
                                    <label>
                                        <input class="form-control" type="text" name="sel_keywords" id="dr_keywords" value="{$data['keywords']}">
                                    </label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group ">
                            <label class="col-md-2 control-label">
                                <span class="le_required">*</span>
                                {fc_lang('课程售价')}：
                            </label>
                            <div class="col-md-9">
                                <div class="radio-list">
                                    <label>
                                        <input class="form-control" type="text" name="sel_price" id="dr_sel_price" value="{$data['course_price']}">
                                    </label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group ">
                            <label class="col-md-2 control-label">
                                <span class="le_required">*</span>
                                {fc_lang('市场价')}：
                            </label>
                            <div class="col-md-9">
                                <div class="radio-list">
                                    <label>
                                        <input class="form-control" type="text" name="del_price" id="dr_del_price" value="{$data['market_price']}">
                                    </label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group ">
                            <label class="col-md-2 control-label">
                                <span class="le_required">*</span>
                                {fc_lang('权重排序(值越大,排序越靠前)')}：
                            </label>
                            <div class="col-md-9">
                                <div class="radio-list">
                                    <label>
                                        <input class="form-control" type="text" name="del_sort" id="dr_del_sort" value="{$data['market_sort']}">
                                    </label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-2 control-label">
                                <span class="le_required">*</span>
                                {fc_lang('上传课程封面')}：
                            </label>
                            <div class="col-md-9">
                                <label class="update-class-pic">
                                    <span class="image-data">未选择任何档案</span>
                                    <!--{dr_field_input('cover','Text',$field['cover']['setting'], $data['cover'])}-->
                                    <input type="file" id="load_img" name="img" onchange ="uploadFile()"/>
                                    <span class="update-word-add">
                                        <p>+</p>
                                        <p>上传图片</p>
                                        {if !empty($data['cover'])}
                                             <img src="{$data['cover']}"/>
                                        {/if}
                                    </span>
                                </label>
                                <p>只能上传jpg/png格式文件，文件不能超过100kb</p>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-2 control-label">
                                <span class="le_required">*</span>
                                {fc_lang('课程详细信息编辑')}：
                            </label>
                            <div class="col-md-9">
                                <div class="radio-list">
                                    <label>{dr_field_input('content', 'TextArea',$field['content']['remark'], $data['content'])}</label>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-page-3">

                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="myfooter">
        <div class="row">
            <div class="portlet-body form">
                <div class="form-body">
                    <div class="form-actions">
                        <div class="row">
                            <div class="col-md-12 text-center">
                                <a class="btn green next-wright-class">{fc_lang('下一步')}</a>
                                <a class="btn green pre-record-class">{fc_lang('上一步')}</a>
                                <!-- <a class="btn green next-record-class">{fc_lang('下一步')}</a> -->
                                <a class="btn green cancel" href="./admin.php?c=publics&m=main">{fc_lang('取消')}</a>
                                <button type="submit" class="btn green save">{fc_lang('保存')}</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</form>
<script>
    //点击上传
    // $(function(){
    //     $("#files").change(function () {
    //         console.log(($("#files").val()));
    //     });
    //
    //     $('#files').change(function(){
    //         var strHtml = "";
    //         for(var intI=0;intI<files.length;intI++){
    //             var tmpFile = files[intI];
    //             var reader = new FileReader();//每循环一次都要重新new一个FileReader实例
    //             reader.readAsDataURL(tmpFile);
    //             reader.onload=function(e){
    //                 alert(e.target.result);
    //                 strHtml += "<img src='"+e.target.result+"' alt=''/>";
    //                 $("prevUpload").innerHTML = "<li>"+strHtml+"</li>";
    //             };
    //         }
    //
    //     });
    //
    //
    //
    //
    // });



    // function getFullPath(obj)
    // {
    //     if(obj)
    //     {
    //         //ie
    //         if (window.navigator.userAgent.indexOf("MSIE")>=1)
    //         {
    //             obj.select();
    //             return document.selection.createRange().text;
    //         }
    //         //firefox
    //         else if(window.navigator.userAgent.indexOf("Firefox")>=1)
    //         {
    //             if(obj.files)
    //             {
    //                 return obj.files.item(0).getAsDataURL();
    //             }
    //             return obj.value;
    //         }
    //         return obj.value;
    //     }
    // }
    //
    // var accessKeyId = "LTAIEvlPaoHFZQNK";
    // var accessKeySecret = "Us5ShPEqXzVPCibT4qZvvYsQZAE7AD";
    // var secretToken = "CAISjgJ1q6Ft5B2yfSjIqabwfvaNibBDgamscUf33VYxY9hViLbesjz2IHtKenZsCegav/Q3nW1V7vsdlrBtTJNJSEnDKNF36pkS6g66eIvGvYmz5LkJ0ER9j4dcT0yV5tTbRsmkZu6/E67fUzKpvyt3xqSAO1fGdle5MJqPpId6Z9AMJGeRZiZHA9EkQGkPtsgWZzmzWPG2KUyo+B2yanBloQ1hk2hyxL2iy8mHkHrkgUb91/UeqvaaQPHmTbE1Z88kAofpgrcnJvKfiHYI0XUQqvcq1p4j0Czco9SQD2NW5xi7KOfO+rVtVlQiOPZlR/4c8KmszaQl57SOyJ6U1RFBMexQVD7YQI2wGDdS2XJ/9rwagAE4U2pFoP6wO5FjADB+jhNGY5bWzEUlxZcxU+e38udj2tc3+7X69V9b0fS7NRC7gsNLIrSZFEYgWgF6wM2weVvu5HJl/54c/GT9ItqqnjYE613kGWeJ6a7DqjWxZMKRs5F09mUTNsXFR+no9JTk+K/tdlA/1wuWOIvrAmPOsytzWw==";
    //
    // var uploader = new AliyunUpload.Vod({
    //     // 文件上传失败
    //     'onUploadFailed': function (uploadInfo, code, message) {
    //         console.log("onUploadFailed: file:" + uploadInfo.file.name + ",code:" + code + ", message:" + message);
    //     },
    //     // 文件上传完成
    //     'onUploadSucceed': function (uploadInfo) {
    //         console.log("onUploadSucceed: " + uploadInfo.file.name + ", endpoint:" + uploadInfo.endpoint + ", bucket:" + uploadInfo.bucket + ", object:" + uploadInfo.object);
    //     },
    //     // 文件上传进度
    //     'onUploadProgress': function (uploadInfo, totalSize, loadedPercent) {
    //         console.log("onUploadProgress:file:" + uploadInfo.file.name + ", fileSize:" + totalSize + ", percent:" + (loadedPercent * 100.00).toFixed(2) + "%");
    //     },
    //     // STS临时账号会过期，过期时触发函数
    //     'onUploadTokenExpired': function (uploadInfo) {
    //         console.log("onUploadTokenExpired");
    //         if (isVodMode()) {
    //             // 实现时，根据uploadInfo.videoId从新获取UploadAuth
    //             //实际环境中调用点播的刷新上传凭证接口，获取凭证
    //             //https://help.aliyun.com/document_detail/55408.html?spm=a2c4g.11186623.6.630.BoYYcY
    //             //获取上传凭证后，调用setUploadAuthAndAddress
    //             // uploader.resumeUploadWithAuth(uploadAuth);
    //         } else if (isSTSMode()) {
    //             // 实现时，从新获取STS临时账号用于恢复上传
    //             // uploader.resumeUploadWithSTSToken(accessKeyId, accessKeySecret, secretToken, expireTime);
    //         }
    //     },
    //     onUploadCanceled:function(uploadInfo)
    //     {
    //         console.log("onUploadCanceled:file:" + uploadInfo.file.name);
    //     },
    //     // 开始上传
    //     'onUploadstarted': function (uploadInfo) {
    //         if (isVodMode()) {
    //             if(!uploadInfo.videoId)//这个文件没有上传异常
    //             {
    //                 //mock 上传凭证，实际产品中需要通过接口获取
    //                 var uploadAuth = '';
    //                 var uploadAddress = '';
    //                 var videoId = '';
    //                 //实际环境中调用调用点播的获取上传凭证接口
    //                 //https://help.aliyun.com/document_detail/55407.html?spm=a2c4g.11186623.6.629.CH7i3X
    //                 //获取上传凭证后，调用setUploadAuthAndAddress
    //                 uploader.setUploadAuthAndAddress(uploadInfo, uploadAuth, uploadAddress,videoId);
    //             }
    //             else//如果videoId有值，根据videoId刷新上传凭证
    //             {
    //                 //mock 上传凭证 实际产品中需要通过接口获取
    //                 var uploadAuth = document.getElementById("uploadAuth").value;
    //                 var uploadAddress = document.getElementById("uploadAddress").value;
    //                 //实际环境中调用点播的刷新上传凭证接口，获取凭证
    //                 //https://help.aliyun.com/document_detail/55408.html?spm=a2c4g.11186623.6.630.BoYYcY
    //                 //获取上传凭证后，调用setUploadAuthAndAddress
    //                 uploader.setUploadAuthAndAddress(uploadInfo, uploadAuth, uploadAddress);
    //             }
    //         }
    //         else if (isSTSMode()) {console.log(uploadInfo);console.log(uploadInfo.file);
    //             // var accessKeyId = document.getElementById("accessKeyId").value;
    //             // var accessKeySecret = document.getElementById("accessKeySecret").value;
    //             // var secretToken = document.getElementById("secretToken").value;
    //             uploader.setSTSToken(uploadInfo, accessKeyId, accessKeySecret,secretToken, "test");
    //         }
    //         console.log("onUploadStarted:" + uploadInfo.file.name + ", endpoint:" + uploadInfo.endpoint + ", bucket:" + uploadInfo.bucket + ", object:" + uploadInfo.object);
    //         var strTem="";  // 临时变量
    //         for(value in uploadInfo){
    //             console.log(value+'：'+uploadInfo[value]);
    //             // strTem+=value+'：'+uploadInfo[value]+"\n";
    //         }
    //         // console.log(strTem);
    //     }
    //     ,
    //     'onUploadEnd':function(uploadInfo){
    //         console.log("onUploadEnd: uploaded all the files");
    //     }
    // });
    //
    // // 点播上传。每次上传都是独立的鉴权，所以初始化时，不需要设置鉴权
    // // 临时账号过期时，在onUploadTokenExpired事件中，用resumeWithToken更新临时账号，上传会续传。
    // var selectFile = function (event) {
    //     // var endpoint = document.getElementById("endpoint").value;
    //     // var bucket = document.getElementById("bucket").value;
    //     // var objectPre = document.getElementById("objectPre").value;
    //     var endpoint = '';
    //     var bucket = '';
    //     var objectPre = '';
    //     var userData;
    //     var filename = '';
    //     if (isVodMode()) {
    //         userData = '{"Vod":{"UserData":{"IsShowWaterMark":"false","Priority":"7"}}}';
    //     } else {
    //         userData = '{"Vod":{"Title":"this is title.我是标题","Description":"this is desc.我是描述","CateId":"19","Tags":"tag1,tag2,标签3","UserData":"user data"}}';
    //     }
    //     //获取凭证
    //
    //     for(var i=0; i<event.target.files.length; i++) {
    //         console.log("add file: " + event.target.files[i].name);
    //         // filename = event.target.files[i].name;
    //         // $.ajax({
    //         //     type:"POST",
    //         //     url:"admin.php?c=publics&m=getAuthorvideo",
    //         //     data:{"Action":"CreateUploadVideo","Title":"我要测试" ,"FileName":filename,"Format":"JSON","Version":'2017-03-21',"AccessKeyId":accessKeyId,
    //         //         "SignatureMethod":'HMAC-SHA1',"SignatureVersion":1.0},
    //         //     success:function (data) {
    //         //         console.log(data);
    //         //     }
    //         //
    //         // });
    //         if (isVodMode()) {
    //             // 点播上传。每次上传都是独立的OSS object，所以添加文件时，不需要设置OSS的属性
    //             uploader.addFile(event.target.files[i], null, null, null, userData);
    //         } else if(isSTSMode()) {
    //             // STS的上传方式，需要在userData里指定Title
    //             var object = objectPre;
    //             // if(objectPre)
    //             // {
    //             //     object = objectPre +"/"+ event.target.files[i].name;
    //             // }
    //             uploader.addFile(event.target.files[i], endpoint, bucket, object , userData);
    //         }
    //     }
    //     //获取上传凭证
    //     // $.post({
    //     //     url:"http://vod.cn-shanghai.aliyuncs.com",
    //     //     data:{"Action":"CreateUploadVideo","Title":"我要测试","FileName":filename,"Format":"JSON"},
    //     //     success:function (data) {
    //     //         console.log(data);
    //     //     }
    //     // });
    // };
    //
    //
    // // document.getElementById("files")
    // //     .addEventListener('change', selectFile);
    //
    // var textarea=document.getElementById("textarea");
    //
    // function start() {
    //     console.log("start upload.");
    //     uploader.startUpload();
    // }
    //
    // function stop() {
    //     console.log("stop upload.");
    //     uploader.stopUpload();
    // }
    //
    // function resumeWithToken() {
    //     console.log("resume upload with token.");
    //     var uploadAuth = '';
    //
    //     // var accessKeyId = document.getElementById("accessKeyId").value;
    //     // var accessKeySecret = document.getElementById("accessKeySecret").value;
    //     // var secretToken = document.getElementById("secretToken").value;
    //
    //     if (isVodMode()) {
    //         uploader.resumeUploadWithAuth(uploadAuth);
    //     } else if (isSTSMode()) {
    //         uploader.resumeUploadWithSTSToken(accessKeyId, accessKeySecret, secretToken);
    //     }
    // }
    //
    // function clearInputFile()
    // {
    //     var ie = (navigator.appVersion.indexOf("MSIE")!=-1);
    //     if( ie ){
    //         var file = document.getElementById("files");
    //         var file2= file.cloneNode(false);
    //         file2.addEventListener('change', selectFile);
    //         file.parentNode.replaceChild(file2,file);
    //     }
    //     else
    //     {
    //         document.getElementById("files").value = '';
    //     }
    //
    // }
    //
    // function clearList() {
    //     console.log("clean upload list.");
    //     uploader.cleanList();
    // }
    //
    // function getList() {
    //     console.log("get upload list.");
    //     var list = uploader.listFiles();
    //     for (var i=0; i<list.length; i++) {
    //         console.log("file:" + list[i].file.name + ", status:" + list[i].state + ", endpoint:" + list[i].endpoint + ", bucket:" + list[i].bucket + ", object:" + list[i].object);
    //     }
    // }
    //
    // function deleteFile() {
    //     if (document.getElementById("deleteIndex").value) {
    //         var index = document.getElementById("deleteIndex").value
    //         log("delete file index:" + index);
    //         uploader.deleteFile(index);
    //     }
    // }
    //
    // function cancelFile() {
    //     if (document.getElementById("cancelIndex").value) {
    //         var index = document.getElementById("cancelIndex").value
    //         log("cancel file index:" + index);
    //         uploader.cancelFile(index);
    //     }
    // }
    //
    // function resumeFile() {
    //     if (document.getElementById("resumeIndex").value) {
    //         var index = document.getElementById("resumeIndex").value
    //         log("resume file index:" + index);
    //         uploader.resumeFile(index);
    //     }
    // }
    //
    // function clearLog() {
    //     textarea.options.length = 0;
    // }
    //
    // // function log(value) {
    // //     if (!value) {
    // //         return;
    // //     }
    // //
    // //     var len = textarea.options.length;
    // //     if (len > 0 && textarea.options[len-1].value.substring(0, 40) == value.substring(0, 40)) {
    // //         //textarea.remove(len-1);
    // //     } else if (len > 25) {
    // //         textarea.remove(0);
    // //     }
    // //
    // //     var option=document.createElement("option");
    // //     option.value=value,option.innerHTML=value;
    // //     textarea.appendChild(option);
    // // }
    //
    // function isVodMode() {
    //     var uploadAuth = ''
    //     return (uploadAuth && uploadAuth.length > 0);
    // }
    //
    // function isSTSMode() {
    //     // var secretToken = secretToken;console.log(secretToken);
    //     if (!isVodMode()) {
    //         if (secretToken && secretToken.length > 0) {
    //             return true;
    //         }
    //     }
    //     return false;
    // }

</script>


{template nfooter.html}